<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
  <title></title>
  <script language="javascript" src="http://webapi.amap.com/maps?v=1.3&amp;key=e8496e8ac4b0f01100b98da5bde96597"></script>
  <script src="http://www.gc.com/H5/map/address.js"></script>
</head>
<body>

<a id="distance" onclick="getDistance()">获取距离</a>
<script>
  //获取当前位置(方法名)
  mMap.getSessionLocation(locationFunc);
  function locationFunc(){
    var data = JSON.parse(sessionStorage.getItem("location"));
    console.log(data);
    alert("您当前位置:"+data.formattedAddress);
    alert("lng:"+data.position.lng);
    alert("lat:"+data.position.lat)
  }

  // 获取两点的距离 (m)
  function getDistance(){
    var obj1={lng:116.39,lat: 39.98};
    var obj2={lng:116.39,lat: 38.98};
    alert(mMap.distance(obj1,obj2));
    mMap.serverDistance(obj1,obj2);
  }
</script>
</body>
</html>